<script setup>
import { ref, watch } from 'vue';

const totalCount = ref(100)
const msg = ref('hello')

// 支持监听多个值
watch([totalCount,msg], (newValue, oldValue) => {
  console.log('totalCount',newValue, oldValue)
})
// 侦听一个响应式数据
watch(totalCount, (newValue, oldValue) => {
  console.log('totalCount',newValue, oldValue)
})
</script>

<template>
<!-- 结构 -->
<h1>{{ totalCount }}</h1>
<button @click="totalCount++">点击累加</button>
<button @click="msg += '~'">{{ msg }}</button>
</template>

<style scoped>
/* 样式 */

</style>
